package br.com.sovi.gwt.client.controleunitario;

import br.com.sovi.gwt.client.ImagesImpl;
import br.com.sovi.gwt.client.entity.ControleUnitario;

import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.form.Label;

public class ControleUnitarioMainMenuPanel extends Panel {

	private Label messageLabel;

	public ControleUnitarioMainMenuPanel(final ControleUnitarioCentralPanel panel) {

		ControleUnitarioTrafegoMenuPanel controleUnitarioTrafegoMenuPanel = new ControleUnitarioTrafegoMenuPanel();
		controleUnitarioTrafegoMenuPanel.setSelectionListener(new ControleUnitarioTrafegoMenuPanel.SelectionListener() {
			@Override
			public void onClick(ControleUnitario points) {
				panel.populateScreen(points);
			}
		});
		this.add(controleUnitarioTrafegoMenuPanel);

		ControleUnitarioMontanhismoMenuPanel controleUnitarioMontanhismoMenuPanel = new ControleUnitarioMontanhismoMenuPanel();
		controleUnitarioMontanhismoMenuPanel
				.setSelectionListener(new ControleUnitarioMontanhismoMenuPanel.SelectionListener() {
					@Override
					public void onClick(ControleUnitario points) {
						panel.populateScreen(points);
					}
				});
		this.add(controleUnitarioMontanhismoMenuPanel);

		buildEmptyPortalMessage();
		this.add(messageLabel);
	}

	public void buildEmptyPortalMessage() {
		StringBuilder sb = new StringBuilder();
		sb.append("<table><tr>");
		sb.append("<td>").append(ImagesImpl.get().up().getHTML()).append("</td>");
		sb
				.append("<td><div style='font-size: 12px; font-weight: bold; font-family: Arial'>Selecione um ou mais rastreamentos acima para ver no mapa.</div></td>");

		messageLabel = new Label();
		messageLabel.setHtml(sb.toString());
	}

	public void hideEmptyPortalMessage() {
		this.remove(messageLabel);
		messageLabel.setVisible(false);
	}
}